package com.item.service;

import com.item.dao.EssenceMapper;
import com.item.dao.model.Essence;
import com.item.dao.model.EssenceExample;
import com.item.daoEx.EssenceMapperEx;
import com.item.daoEx.model.EssenceEx;
import com.item.util.MyDateUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EssenceService {
    @Autowired
    private EssenceMapper essenceMapper;
    
    @Autowired
    private EssenceMapperEx essenceMapperEx;

    private static final Logger logger = Logger.getLogger(EssenceService.class);

    public int countByExample(EssenceExample example) {
        return this.essenceMapper.countByExample(example);
    }

    public Essence selectByPrimaryKey(String id) {
        return this.essenceMapper.selectByPrimaryKey(id);
    }

    public List<Essence> selectByExample(EssenceExample example) {
        return this.essenceMapper.selectByExample(example);
    }

    public int deleteByPrimaryKey(String id) {
        return this.essenceMapper.deleteByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Essence record) {
        return this.essenceMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Essence record) {
        return this.essenceMapper.updateByPrimaryKey(record);
    }

    public int deleteByExample(EssenceExample example) {
        return this.essenceMapper.deleteByExample(example);
    }

    public int updateByExampleSelective(Essence record, EssenceExample example) {
        return this.essenceMapper.updateByExampleSelective(record, example);
    }

    public int updateByExample(Essence record, EssenceExample example) {
        return this.essenceMapper.updateByExample(record, example);
    }

    public int insert(Essence record) {
        return this.essenceMapper.insert(record);
    }

    public int insertSelective(Essence record) {
        return this.essenceMapper.insertSelective(record);
    }
    
    public List<EssenceEx> getEssenceEx(Map<?,?> map){
    	return this.essenceMapperEx.getEssenceEx(map);
    }
    
    public List<Essence> getMyEssence(Map<?,?> map){
    	return this.essenceMapperEx.getMyEssence(map);
    }
    
    public int addEssenceDownload(Essence essence){
    	return this.essenceMapperEx.addEssenceDownload(essence);
    }
    
    public List<String> getRecomendKeys(Map<?,?> map){
    	return this.essenceMapperEx.getRecomendKeys(map);
    }
    
    public int getTodayCount(){
    	EssenceExample eex = new EssenceExample();
    	eex.createCriteria().andDateEqualTo(MyDateUtils.parseDateWithDay(new Date()));
    	return this.essenceMapper.countByExample(eex);
    }
}